package com.demo.webapp.kcfinder.config;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

/**
 * 结果类型配置类
 * 框架提供若干结果类型对象,用来执行View层的渲染。
 * 当一个Action执行后,返回的执行结果映射字段来选取使用何种类型的结果对象进行渲染。
 * @author ryuu.kk
 *
 */
public class ResultTypeConfig implements Serializable {

	/**
	 * 版本序列化ID
	 */
	private static final long serialVersionUID = -5552150436350420723L;
	protected String name;
	protected String className;
	protected Map<String, String> params;
	
	public ResultTypeConfig(String name, String className) {
		this.name = name;
		this.className = className;
		this.params = new HashMap<String, String>();
	}
	
	public ResultTypeConfig(String name, String className, Map<String,String> params) {
		this.name = name;
		this.className = className;
		this.params = params;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}

	public Map<String, String> getParams() {
		return params;
	}

	public void setParams(Map<String, String> params) {
		this.params = params;
	}
	
	public void set(String key, String value) {
		if (StringUtils.isBlank(key)) {
			return;
		}
		if (this.params == null) {
			params = new HashMap<String, String>();
		}
		params.put(key, value);
	}
}